<?php
require_once 'config.php';
require_once 'classes/data/User.php';

/**
 * This class represents a view in the system.
 */
final class View  
{
	/**
	 * The data of the view
	 */
	public $data = array(); /*array*/
	
	private static $PAGE_TITLES = array(
			'login' => 'Login',
			'register' => 'Register',
			'category' => 'Photoalbum',
			'photo' => 'Photo',
			'profile' => 'Profile');
	
    /**
     * Displays the view with the given filename.
     * 
     * @param string $filename
     * 		  The filename of the view which will be displayed.
     * 
     * @param string $title
     * 		  The title of the view which will be displayed.
     */
    public function display(/*string*/ $filename) 
    {
    	/*string*/ $fullViewFilename = ROOT_DIR . '/views/' . $filename . '.php';
    	if (!file_exists($fullViewFilename))
    	{
    		throw new Exception('Unable to navigate to ' . $fullViewFilename . '. The file doesn\'t exist.');
    	}
    	
    	/*string*/ $content = 'views/' . $filename . '.php';
    	$this->data['title'] = self::$PAGE_TITLES[$filename];
    	include 'views/layout.php';
    }
} // end class
?>